
package ru.android.hamchat;

import ru.android.hamchat.R;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class HamChatActivity extends Activity {
    
	private EditText mCommon;
	private EditText mPromt;
	private HamChat chatCore;
    
    public HamChatActivity() {
    }

    /** Called with the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.hamchat_activity);

        mCommon = (EditText) findViewById(R.id.commonText);
        mPromt = (EditText) findViewById(R.id.promtText);

        ((Button) findViewById(R.id.buttonSend)).setOnClickListener(mSendListener);
        chatCore = new HamChat();
        chatCore.setBotName(getText(R.string.bot_name).toString());
        chatCore.setUserName(getText(R.string.user_name).toString());
        
        mCommon.setText(chatCore.getCommonText());
        mPromt.setText("");

    }

    /**
     * Called when the activity is about to start interacting with the user.
     */
    @Override
    protected void onResume() {
        super.onResume();
    }

    OnClickListener mSendListener = new OnClickListener() {
        public void onClick(View v) {
            chatCore.sendMessage(mPromt.getText().toString());
            chatCore.reply();
            mCommon.setText(chatCore.getCommonText());
            
        }
    };
    
    
    }
